package PackageButton;

import javax.swing.*;
import java.awt.*;

public class Test {
    public Test(){
        JFrame jFrame = new JFrame();
        jFrame.setSize(400, 200);
        jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        jFrame.setLayout(new FlowLayout());

        JButton button1 = new JButton();
        JButton button2 = new JButton("测试的字符串");
        button2.addActionListener(e -> {
            JButton jb = (JButton) e.getSource();
            button1.setText(jb.getText());

        });
        jFrame.add(button1);
        jFrame.add(button2);
        jFrame.setVisible(true);
    }
    public static void main(String[] args) {
        new Test();
    }
}
